package robot;

import org.apache.log4j.Logger;

import messageTreater.EventMachine;

public class AnswerMachine {
	private String lastItemID = "0";
	private Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * @deprecated
	 */
	public String getAnswer(String ques) {
		MenuTreater treater = new MenuTreater();
		String itemID = treater.getItemID(lastItemID, ques);
		String actionResult = new Worker().takeActionOf(itemID);
		
		if(actionResult!=null) {
			String questionText = treater.getItemText(itemID);
			String[] options = treater.getOptions(itemID);
			String result = questionText + "\n<br>";
			
			for(int i=0 ; i<options.length ; i++) {
				result = result + options[i] + "\n<br>";
			}
			lastItemID = itemID;
			return result;
		} else {
			return "error message";
		}
	}
	
	public String getAnswer(String type, String uName, String message) {
		if(type.equals("subscribe")) {
			return "哎，生面孔，欢迎欢迎，跟胖哥说话速度打1";
		} else if(type.equals("")) {
			
		}
		return message;
	}
	
	public String getEvents(String uName, String message) {
		log.info("in getEvents");
		return new EventMachine().getNewEvent(uName);
	}
}